<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>垃圾投递订单</title>
    <link rel="stylesheet" href="pages/layui/css/layui.css" media="all">
    <script src="pages/layui/layui.js"></script>
    <script src="js/config.js"></script>
    <script src="js/reqInterceptor.js"></script>
    <style>
        body{margin: 10px;}
        label[name='zhi']{
            width: 10px;
            margin-left: 0;
            padding-left: 0;
        }
    </style>
</head>
<body>
<div>
    <form class="layui-form" id="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">订单编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="orderId" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">设备编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="deviceNumber" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">设备场地</label>
                <div class="layui-input-inline">
                    <select name="venuesId" class="venuesId" lay-verify="venuesId" lay-filter="venuesId">
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">设备地址</label>
                <div class="layui-input-inline">
                    <input type="text" name="deviceAddress" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">用户昵称</label>
                <div class="layui-input-inline">
                    <input type="text" name="nickName" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">用户手机号</label>
                <div class="layui-input-inline">
                    <input type="text" name="userPhone" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">回收类型</label>
                <div class="layui-input-inline">
                    <select name="recyclingType" class="recyclingType" lay-verify="recyclingType" lay-filter="recyclingType">
                        <option value="">请选择</option>
                        <option value="1">纸类/塑料/金属</option>
                        <option value="2">织物/其他</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">创建时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="beginDate" class="layui-input test-item" placeholder="开始日期">
                </div>
                <label class="layui-form-label" name="zhi">至</label>
                <div class="layui-input-inline">
                    <input type="text" name="endDate" class="layui-input test-item" placeholder="结束日期">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">投递方式</label>
                <div class="layui-input-inline">
                    <select name="deliverType" class="deliverType" lay-verify="deliverType" lay-filter="deliverType">
                        <option value="">请选择</option>
                        <option value="1">扫码</option>
                        <option value="2">IC卡</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">设备所属分拣中心</label>
                <div class="layui-input-inline">
                    <select name="sortingId" class="sortingId" lay-verify="sortingId" lay-filter="sortingId">
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">设备所属运营商</label>
                <div class="layui-input-inline">
                    <select name="operatorsId" class="operatorsId" lay-verify="operatorsId" lay-filter="operatorsId">
                    </select>
                </div>
            </div><div class="layui-inline">
                <label class="layui-form-label">设备所属合伙人</label>
                <div class="layui-input-inline">
                    <select name="partnersId" class="partnersId" lay-verify="partnersId" lay-filter="partnersId">
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1" id="demo1">查询</button>
            </div>
            <div class="layui-inline">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="demo2" id="demo2">导出</button>
            </div>
        </div>
    </form>
</div>
<table class="layui-hide" id="demo" lay-filter="demo"></table>
<script>
    layui.use([ 'layer', 'table', 'element', 'form','laydate'], function(){
        var layer = layui.layer //弹层
                ,table = layui.table //表格
                ,element = layui.element //元素操作
                ,$ =layui.$
                ,form =layui.form
                ,laydate=layui.laydate;

        lay('.test-item').each(function(){
            laydate.render({
                elem: this
                ,trigger: 'click'
            });
        });
       //检查项目添加到下拉框中
        $.ajax({
            url: config.gatewayUri+"/"+config.orderServiceId+'/api/garbage-recycling-order/admin/getBackVenuesList',
            dataType: 'json',
            type: 'get',
            success: function (res) {
                $(".venuesId").append(new Option("请选择",""));
                $.each(res, function (index, item) {
                    $('.venuesId').append(new Option(item.venuesname, item.venuesid));// 下拉菜单里添加元素
                });
                layui.form.render("select");
                //重新渲染 固定写法
            }
        });
         $.ajax({
            url: config.gatewayUri+"/"+config.orderServiceId+'/api/garbage-recycling-order/admin/getPartnersList',
            dataType: 'json',
            type: 'get',
            success: function (res) {
                $(".partnersId").append(new Option("请选择",""));
                $.each(res, function (index, item) {
                    $('.partnersId').append(new Option(item.username, item.partnersid));// 下拉菜单里添加元素
                });
                layui.form.render("select");
                //重新渲染 固定写法
            }
        });
        $.ajax({
            url: config.gatewayUri+"/"+config.orderServiceId+'/api/garbage-recycling-order/admin/getSortingOrOperatorsList',
            data:{managerType:3},
            dataType: 'json',
            type: 'get',
            success: function (res) {
                $(".sortingId").append(new Option("请选择",""));
                $.each(res, function (index, item) {
                    $('.sortingId').append(new Option(item.username, item.managerid));// 下拉菜单里添加元素
                });
                layui.form.render("select");
                //重新渲染 固定写法
            }
        });
        $.ajax({
            url: config.gatewayUri+"/"+config.orderServiceId+'/api/garbage-recycling-order/admin/getSortingOrOperatorsList',
            data:{managerType:4},
            dataType: 'json',
            type: 'get',
            success: function (res) {
                $(".operatorsId").append(new Option("请选择",""));
                $.each(res, function (index, item) {
                    $('.operatorsId').append(new Option(item.username, item.managerid));// 下拉菜单里添加元素
                });
                layui.form.render("select");
                //重新渲染 固定写法
            }
        });
        //监听提交
        form.on('submit(demo1)', function(data){
            table.reload('demo',{
                where:data.field
            });
            return false;
        });
        //执行一个 table 实例
        table.render({
            elem: '#demo'
            ,height: 480
            ,url: config.gatewayUri+"/"+config.orderServiceId+'/api/garbage-recycling-order/admin/getGarbageRecyclingOrderList' //数据接口
            ,method: 'post'
            ,page: true //开启分页
            ,limit:5
            ,limits:[5,10,15,20]
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'orderid', title: '订单编号', width:80, fixed: 'left'}
                ,{field: 'devicenumber', title: '设备编号', width:150}
                ,{field: 'venuesname', title: '设备场地', width: 90}
                ,{field: 'deviceaddress', title: '设备地址', width: 100}
                ,{field: 'sortingname', title: '所属分拣中心', width: 120}
                ,{field: 'operatorsname', title: '所属运营商', width: 120}
                ,{field: 'partnersname', title: '所属合伙人', width: 120}
                ,{field: 'nickName', title: '用户昵称', width: 100}
                ,{field: 'userPhone', title: '用户手机号', width:150}
                ,{field: 'recyclingweight', title: '总重量(kg)', width: 70}
                ,{field: 'accpoints', title: '总积分', width: 80}
                ,{field: 'delivertype', title: '投递方式', width: 70,templet:function(d){
                    if(d.delivertype==1){
                        return '扫码'
                    }else{
                        return 'IC卡'
                    }
                }}
                ,{field: 'ctime', title: '创建时间', width: 180,templet:function(d){
                    return layui.util.toDateString((d.ctime), "yyyy-MM-dd HH:mm:ss")
                }}
            ]]
            ,response:{
                statusCode:'200'
            }
            ,parseData:function(res){
                return {
                    "code":res.code,
                    "msg":res.msg,
                    "count":res.data.total,
                    "data":res.data.list
                }
            }
        });
    });
</script>
</body>
</html>